﻿#pragma once
#include <opencv2/opencv.hpp> //cvThreshold
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <cmath>

namespace ImageQuaEv
{
	bool IsValidInts(int imgarr[]);

	float modeInts(const cv::Mat&Img512, int&modeInts); //return MeanInts

	void SerachGoodPeak16bit(const cv::Mat &img, std::vector<cv::Point2i> &peak);
	void SerachGoodPeak8bit(const cv::Mat &img, std::vector<cv::Point2i> &peak);

	int GetImgQua(const cv::Mat& img, double& midScore, double& intensity, int nRoiSize = 256);
	int GetImgDetialQua(const cv::Mat& img, double& midScore, double& intensity, std::vector<float>& intenvec, int nRoiSize = 256);
	int midScoreSelf(const cv::Mat& img, double& midScore, double& intensity);

	void SpotFilterKK(cv::Mat& imag, const cv::Mat& rawim, cv::Mat& inoise);
	void OtsuThresholdKK(const cv::Mat& imgGrayt, int& sth, const cv::Mat& bimt);
	float binaryThresholdKK(const cv::Mat& imaget, const cv::Mat& imgt, int& mp);
	int getThresholdKK(cv::Mat& imgt, std::vector<int> &histData, int imageType, int offset);
	void fastLaunchKK(cv::Mat& noise, cv::Mat& intensity, std::vector<cv::Point2i>& resultPos, float sth);
	int CalcMatQuaKK(const cv::Mat &img, double &midScore, double &intensity, bool &overExposure);
	void getFimg(std::vector<cv::Point2i>& resultPos, cv::Mat& img1, int __ImageHeight, int __ImageWidth);

	int midScoreSelfKK(const cv::Mat& img, double& midScore, double& intensity, bool &overExposure);

	std::vector<std::vector<int>> ScoreHeatMapSelf(const cv::Mat& img, std::vector<std::vector<double>>& midScore, std::vector<std::vector<double>>& intensity);
}
